<?php

class NewsinfoAction extends BaseAction{
	public function index(){
		
			import('ORG.Util.Page');	// 导入分页类
		//$count      = M('Company')->where('status=1')->count();	// 查询满足要求的总记录数
			$count      = M('news')->count();	// 查询满足要求的总记录
			$Page       = new Page($count,25);	//实例化分页类 传入总记录数和每页显示的记录数
			$show       = $Page->show();	// 分页显示输出
			// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
			//$list = M('Company')->where('status=1')->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
			$list = M('news')->order('id DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
	
		//$list = M('news')->order('id ASC')->select();
		$this->assign('list',$list);
		$this->assign("count",$count);
		$this->assign('page',$show);// 赋值分页输出
		$this->display();	
		}
		
	public function view(){
		$id = empty($_GET['id'])?exit():$_GET['id'];
		$newcon = M('news')->where('id='.$id)->find();
		
		$news = M('news')->order('id DESC')->limit(8)->select();		
		
		$catename = M('Category')->select();
		$this->assign('newcon',$newcon);
		$this->assign('catename',$catename);
		$this->assign('news',$news);
		$this->display();	
		}
	}
?>